﻿@using Pro260Website.Models
@model Pro260Website.Models.SliderListingModel

@{
    ViewBag.Title = "Games";
    var ajaxOptions = new AjaxOptions
    {
        UpdateTargetId = "updateItem",
        Url = Url.Action("List", "Game", new {viewname = "GetSliderImages"}),
    };
}
<head>
    <script src="@Url.Content("~/Scripts/jquery-ui-custom.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.jcoverflip.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    
    <script type="text/javascript">
        var searchString;
        var timeClock;
        var lastTimeClock;
        
        function showHint() {
            var xmlhttp;

            if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp = new XMLHttpRequest();
            }
            xmlhttp.onreadystatechange = function () {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

                    document.getElementById("updateItem").innerHTML = xmlhttp.responseText;
                    load();
                }
            }
            xmlhttp.open("GET", "List?searchFor=" + document.getElementById("searchFor").value +"&view=GetSliderImages", true);
            xmlhttp.send();
            

        }
        
        function start(str) {

            searchString = str;
            if (timeClock) {
                clearTimeout(timeClock);
                timeClock = setTimeout("showHint()", 250);
            }
            else {
                timeClock = setTimeout("showHint()", 250);
                lastTimeClock = setTimeout("showHint()", 2000);
            }
        }
    </script>
</head>
<div id="formBackground">
    <h1 class="title @Html.GetColor(Request.Cookies["color"])">Games</h1>
    <br/><br/><br/>
    <div>
        @Html.ActionLink("View History", "ShowHistory", null, new { @class= "actionButtons " + @Html.GetColor(Request.Cookies["color"])} )
        @Html.ActionLink("Suggestions", "ShowSuggestions", null, new { @class = "actionButtons " + @Html.GetColor(Request.Cookies["color"]) })
    </div>
    <div id="titlelessItem" style="float:right;">
        <div class = "item roundTextBox @Html.GetColor(Request.Cookies["color"])" style="right: 30px; bottom: 50px;">
        @using (Html.BeginForm("List", "Game"))
        {
            <input id="searchFor" type="text" name="searchFor" onkeyup="start(this.value)"/>
            <input type="submit" value="Search" class="actionButtons @Html.GetColor(Request.Cookies["color"])" />
        }
        </div>
    </div><br/><br/>
    
    @using(Ajax.BeginForm(ajaxOptions))
    {
        <div id="updateItem" style="width: 93.5%; height: 360px; overflow:hidden;" class="sideBox @Html.GetColor(Request.Cookies["color"])">
            
            @{
                Html.RenderPartial("GetSliderImages", Model);
            }
        </div>
    }
    <br/><br/>

    @using(Ajax.BeginForm(Model.Items.GameAjaxOptions))
    {
        <div id="gameUpdateItem">
            
        </div>
    }
</div>